package com.ywu.boot.context;

import lombok.Data;
import lombok.Getter;
import lombok.ToString;

/**
 * @ClassName YwuContextHolder
 * @Description TODO
 * @Author GroundDemo
 * @Date 2024/3/16 15:07
 * @Version 1.0
 **/
@Getter
@ToString
public class YwuContextHolder {
    private static ThreadLocal<YwuContext> currentContext = new ThreadLocal<>();

    /**
    * @Author GroundDemo
    * @Description 将数据设置到ThreadLocal对象中
    * @Date 15:11 2024/3/16
    * @Param [ywuContext]
    * @return void
    **/
    public static void setCurrentContext(YwuContext ywuContext) {
        currentContext.set(ywuContext);
    }

    /**
    * @Author GroundDemo
    * @Description 获取当前线程的currentContext对象
    * @Date 15:11 2024/3/16
    * @Param []
    * @return com.ywu.boot.context.YwuContext
    **/
    public static YwuContext getCurrentContext() {
        return currentContext.get();
    }

    /**
    * @Author GroundDemo
    * @Description 删除变量
    * @Date 15:19 2024/3/16
    * @Param []
    * @return void
    **/
    public static void removeCurrentContext() {
        currentContext.remove();
    }
}
